import request from '@/utils/request'
// import qs from 'qs'

// 动态路由

// RIP获取定时器
export function getRipTimers (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/getRipTimers',
    method: 'post',
    data
  })
}

// RIP设置定时器
export function setRipTimers (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/setRipTimers',
    method: 'post',
    data
  })
}

// RIP获取distance
export function getRipDistance (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/getRipDistance',
    method: 'post',
    data
  })
}

// RIP设置distance
export function setRipDistance (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/setRipDistance',
    method: 'post',
    data
  })
}

// RIP获取协议版本
export function getRipVersion (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/getRipVersion',
    method: 'post',
    data
  })
}

// RIP设置协议版本
export function setRipVersion (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/setRipVersion',
    method: 'post',
    data
  })
}

// RIP获取开启RIP的接口
export function getRipInterface (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/getRipInterface',
    method: 'post',
    data
  })
}

// RIP增加开启RIP的接口
export function addRipInterface (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/addRipInterface',
    method: 'post',
    data
  })
}

// RIP删除开启RIP的接口
export function delRipInterface (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/delRipInterface',
    method: 'post',
    data
  })
}

// RIP获取开启的网段
export function getRipNet (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/getRipNet',
    method: 'post',
    data
  })
}

// RIP增加开启的网段
export function addRipNet (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/addRipNet',
    method: 'post',
    data
  })
}

// RIP删除开启的网段
export function delRipNet (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/delRipNet',
    method: 'post',
    data
  })
}

// RIP获取开启被动状态的接口
export function getRipPassiveInterface (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/getRipPassiveInterface',
    method: 'post',
    data
  })
}

// RIP增加开启被动状态的接口
export function addRipPassiveInterface (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/addRipPassiveInterface',
    method: 'post',
    data
  })
}

// RIP删除开启被动状态的接口
export function delRipPassiveInterface (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/delRipPassiveInterface',
    method: 'post',
    data
  })
}

// RIP获取路由
export function getRipRoute (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/getRipRoute',
    method: 'post',
    data
  })
}

// RIP获取接口配置信息
export function getRipIfconfig (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/getRipIfconfig',
    method: 'post',
    data
  })
}

// RIP添加及编辑接口配置信息
export function setRipIfconfig (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/setRipIfconfig',
    method: 'post',
    data
  })
}

// RIP删除接口配置信息
export function delRipIfconfig (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/delRipIfconfig',
    method: 'post',
    data
  })
}

// RIP获取状态
export function getRipStatus (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/getRipStatus',
    method: 'post',
    data
  })
}

// RIP设置状态
export function setRipStatus (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/setRipStatus',
    method: 'post',
    data
  })
}

// 协议重载
export function reloadAgreement (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/reloadAgreement',
    method: 'post',
    data
  })
}

// 获取协议状态
export function getAgreementStatus (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/getAgreementStatus',
    method: 'post',
    data
  })
}

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}

// function fromData (params) {
//   var data = qs.stringify(params)
//   return data
// }
